import BpmnViewer from 'bpmn-js/lib/Viewer.js';

import customTranslate from './modules/translate/customTranslate.js';
import MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas/index.js';
import ModelingModule from 'bpmn-js/lib/features/modeling/index.js';

import camundaModdleDescriptor from 'camunda-bpmn-moddle/resources/camunda.json';

class FlowViewer {
  private viewer: any = null;

  constructor() {}

  init(dom: any) {
    const opts: any = {
      container: dom,
      additionalModules: [
        MoveCanvasModule,
        ModelingModule,
        // 国际化
        customTranslate()
      ],
      moddleExtensions: {
        // camunda的属性定义
        camunda: camundaModdleDescriptor
      }
    };
    this.viewer = new BpmnViewer(opts);
  }
  getViewer() {
    return this.viewer;
  }
}
export const viewer = new FlowViewer();
